
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/bin")
set(LIBRARY_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/build/lib")

#条件编译
if(CMAKE_HOST_UNIX)
    set(CMAKE_C_COMPILER gcc)
    set(CMAKE_CXX_COMPILER g++)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -g -fpic -fPIC")
    set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -D_DEBUG -O0 -ggdb")
    set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2")

elseif (CMAKE_HOST_WIN32)
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # 禁止 strcat 等函数报 strcat_s 警告

    # 设置 OpenSSL 的安装路径，根据你的实际情况修改
    set(OPENSSL_ROOT_DIR "C:/usr/win64/lib")

    # 检测当前使用的编译器
    if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MinGW")
        message(STATUS "Using MinGW compiler")
        
        link_libraries(
            ws2_32
            mswsock
            advapi32
            user32
        )

    elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
        message(STATUS "Using MSVC compiler")

        set(BOOST_ROOT "C:/usr/boost")
        set(Boost_LIBRARY_DIRS  "C:/usr/boost/lib")

        # 设置编译选项，使 UTF8 格式的源文件
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:utf-8 /execution-charset:utf-8")
    
    elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
        message(STATUS "Using Clang compiler")
        
        set(BOOST_ROOT "C:/usr/boost_clang")
        set(Boost_LIBRARY_DIRS "C:/usr/boost_clang/lib")

    else()
        message("Unknown compiler or generator:" ${CMAKE_CXX_COMPILER_ID})
        
    endif()
endif()
